package org.bookie.core.model;

import org.jdom.Element;
import org.jdom.input.DOMBuilder;
import org.w3c.dom.Document;

import com.facebook.api.ProfileField;

/**
 * Class that encapsulate information about FacebookUser
 * 
 * @author zubairov
 */
public class FacebookUser {

	private String name;
	
	private long id;

	public FacebookUser(long id, String name) {
		this.name = name;
	}
	
	public FacebookUser(Document userinfo) {
		DOMBuilder builder = new DOMBuilder();
		org.jdom.Document doc = builder.build(userinfo);
		Element userElement = (Element) doc.getRootElement().getChildren().iterator().next();
		name = userElement.getChildText(ProfileField.NAME.toString(), userElement.getNamespace());
		id = Long.parseLong(userElement.getChildText("uid", userElement.getNamespace()));
	}

	public String getName() {
		return name;
	}
	
	public long getId() {
		return id;
	}
	
}
